Option Strict On
Option Explicit On

Imports System
Imports System.data
Imports System.Collections.Generic

Public MustInherit Class LoadMetadataBase
   Implements ILoadMetadata

   Private mDatabaseName As String
   Private mServerName As String
   Private mSkipStoredProcs As Boolean
   Private mSelectPatterns As String
   Private mSetSelectPatterns As String
   Private mLookupPrefix As String
   Private mTargetLanguage As CodeGenerationSupport.TargetLanguage
   Private mRemoveAllPrefixes As Boolean
   Private mPrefixes As String
   Private mFriendlyCaps As Boolean
   Private mRemoveUnderscores As Boolean
   Private mKeywordTreatment As CodeGenerationSupport.KeywordTreatment
   Private mBlankTreatment As CodeGenerationSupport.BlankTreatment
   Private mColumnRemoveAllPrefixes As Boolean
   Private mColumnPrefixes As String
    Private mColumnRemoveTablePrefix As Boolean
    Private mColumnFriendlyCaps As Boolean
   Private mColumnRemoveUnderscores As Boolean
   Private mColumnKeywordTreatment As CodeGenerationSupport.KeywordTreatment
   Private mColumnBlankTreatment As CodeGenerationSupport.BlankTreatment
   Private mViewIDType As CodeGenerationSupport.ViewIDType
   Private mViewIDText As String
   Private mCustomAttributeNamespace As String
   Private mCustomAttributePrefix As String
   Private mSkipExtendedProperties As Boolean

   Public Sub New(ByVal serverName As String, ByVal databaseName As String)
      Me.mServerName = serverName
      Me.mDatabaseName = databaseName
   End Sub

    Public Function Load( _
             ByVal skipStoredProcs As Boolean, _
             ByVal selectPatterns As String, _
             ByVal setSelectPatterns As String, _
             ByVal lookupPrefix As String, _
             ByVal targetLanguage As CodeGenerationSupport.TargetLanguage, _
             ByVal removeAllPrefixes As Boolean, _
             ByVal prefixes As String, _
             ByVal friendlyCaps As Boolean, _
             ByVal removeUnderscores As Boolean, _
             ByVal keywordTreatment As CodeGenerationSupport.KeywordTreatment, _
             ByVal blankTreatment As CodeGenerationSupport.BlankTreatment, _
             ByVal columnRemoveAllPrefixes As Boolean, _
             ByVal columnPrefixes As String, _
             ByVal columnRemoveTablePrefix As Boolean, _
             ByVal columnFriendlyCaps As Boolean, _
             ByVal columnRemoveUnderscores As Boolean, _
             ByVal columnKeywordTreatment As CodeGenerationSupport.KeywordTreatment, _
             ByVal columnBlankTreatment As CodeGenerationSupport.BlankTreatment, _
             ByVal viewIDType As CodeGenerationSupport.ViewIDType, _
             ByVal viewIDText As String, _
             ByVal customAttributeNamespace As String, _
             ByVal customAttributePrefix As String, _
             ByVal skipExtendedProperties As Boolean) _
             As MetadataWrapper.DbsMetaDataRoot _
             Implements ILoadMetadata.Load
        mSkipStoredProcs = skipStoredProcs
        mSelectPatterns = selectPatterns
        mSetSelectPatterns = setSelectPatterns
        mLookupPrefix = lookupPrefix
        mTargetLanguage = targetLanguage
        mRemoveAllPrefixes = removeAllPrefixes
        mPrefixes = prefixes
        mFriendlyCaps = friendlyCaps
        mRemoveUnderscores = removeUnderscores
        mKeywordTreatment = keywordTreatment
        mBlankTreatment = blankTreatment
        mColumnRemoveAllPrefixes = columnRemoveAllPrefixes
        mColumnPrefixes = columnPrefixes
        mColumnRemoveTablePrefix = columnRemoveTablePrefix
        mColumnFriendlyCaps = columnFriendlyCaps
        mColumnRemoveUnderscores = columnRemoveUnderscores
        mColumnKeywordTreatment = columnKeywordTreatment
        mColumnBlankTreatment = columnBlankTreatment
        mViewIDType = viewIDType
        mViewIDText = viewIDText
        mCustomAttributeNamespace = customAttributeNamespace
        mCustomAttributePrefix = customAttributePrefix
        mSkipExtendedProperties = skipExtendedProperties

        Return InternalLoad()
    End Function

   Protected MustOverride Function InternalLoad() As MetadataWrapper.DbsMetaDataRoot

   Protected Function GetSelectPatterns() As String()
      If SelectPatterns.Trim.Length = 0 Then
         '   mSelectPatterns = New String() {"*Select*"}
         Return New String() {"\w*Select\w*"}
      Else
         Return mSelectPatterns.Split("~"c)
      End If
   End Function

   Protected Function GetSetSelectPatterns() As String()
      If SetSelectPatterns.Trim.Length = 0 Then
         '   mSetSelectPatterns = New String() {"*SetSetSelect*"}
         Return New String() {"\w*SetSetSelect\w*"}
      Else
         Return SetSelectPatterns.Split("~"c)
      End If

   End Function

#Region "Properties"
   Protected ReadOnly Property ServerName() As String
      Get
         Return mServerName
      End Get
   End Property

   Protected ReadOnly Property DatabaseName() As String
      Get
         Return mDatabaseName
      End Get
   End Property

   Protected ReadOnly Property SkipStoredProcs() As Boolean
      Get
         Return mSkipStoredProcs
      End Get
   End Property

   Protected ReadOnly Property SelectPatterns() As String
      Get
         Return mSelectPatterns
      End Get
   End Property
   Protected ReadOnly Property SetSelectPatterns() As String
      Get
         Return mSetSelectPatterns
      End Get
   End Property

   Protected ReadOnly Property LookupPrefix() As String
      Get
         Return mLookupPrefix
      End Get
   End Property

   Protected ReadOnly Property TargetLanguage() As CodeGenerationSupport.TargetLanguage
      Get
         Return mTargetLanguage
      End Get
   End Property

   Protected ReadOnly Property RemoveAllPrefixes() As Boolean
      Get
         Return mRemoveAllPrefixes
      End Get
   End Property
   Protected ReadOnly Property Prefixes() As String
      Get
         Return mPrefixes
      End Get
   End Property
   Protected ReadOnly Property FriendlyCaps() As Boolean
      Get
         Return mFriendlyCaps
      End Get
   End Property
   Protected ReadOnly Property RemoveUnderscores() As Boolean
      Get
         Return mRemoveUnderscores
      End Get
   End Property

   Protected ReadOnly Property KeywordTreatment() As CodeGenerationSupport.KeywordTreatment
      Get
         Return mKeywordTreatment
      End Get
   End Property

   Protected ReadOnly Property BlankTreatment() As CodeGenerationSupport.BlankTreatment
      Get
         Return mBlankTreatment
      End Get
   End Property

   Protected ReadOnly Property ColumnRemoveAllPrefixes() As Boolean
      Get
         Return mColumnRemoveAllPrefixes
      End Get
   End Property

   Protected ReadOnly Property ColumnPrefixes() As String
      Get
         Return mColumnPrefixes
      End Get
   End Property

    Protected ReadOnly Property ColumnRemoveTablePrefix() As Boolean
        Get
            Return mColumnRemoveTablePrefix
        End Get
    End Property

   Protected ReadOnly Property ColumnFriendlyCaps() As Boolean
      Get
         Return mColumnFriendlyCaps
      End Get
   End Property
   Protected ReadOnly Property ColumnRemoveUnderscores() As Boolean
      Get
         Return mColumnRemoveUnderscores
      End Get
   End Property

   Protected ReadOnly Property ColumnKeywordTreatment() As CodeGenerationSupport.KeywordTreatment
      Get
         Return mColumnKeywordTreatment
      End Get
   End Property

   Protected ReadOnly Property ColumnBlankTreatment() As CodeGenerationSupport.BlankTreatment
      Get
         Return mColumnBlankTreatment
      End Get
   End Property

   Protected ReadOnly Property ViewIDType() As CodeGenerationSupport.ViewIDType
      Get
         Return mViewIDType
      End Get
   End Property

   Protected ReadOnly Property ViewIDText() As String
      Get
         Return mViewIDText
      End Get
   End Property

   Protected ReadOnly Property CustomAttributeNamespace() As String
      Get
         Return mCustomAttributeNamespace
      End Get
   End Property

   Protected ReadOnly Property CustomAttributePrefix() As String
      Get
         Return mCustomAttributePrefix
      End Get
   End Property

   Protected ReadOnly Property SkipExtendedProperties() As Boolean
      Get
         Return mSkipExtendedProperties
      End Get
   End Property

#End Region

End Class
